//
//  BonusPrototypes.cpp
//  airfight
//
//  Created by aaron on 12-11-22.
//  Copyright (c) 2012年 moonriver. All rights reserved.
//

#include <iostream>
#include "BonusPrototypes.h"


BonusPrototypes* BonusPrototypes::s_SharedBonusPrototypes = NULL;

BonusPrototypes* BonusPrototypes::getInstance()
{
    static bool s_bFirstUsePrototypes = true;
    if (NULL == s_SharedBonusPrototypes) {
        s_SharedBonusPrototypes = new BonusPrototypes();
        s_bFirstUsePrototypes = false;
        s_SharedBonusPrototypes->init();
    }
    return s_SharedBonusPrototypes;
    
}

BonusPrototypes::BonusPrototypes()
{
    bonusPrototype_Dict = NULL;
}

bool BonusPrototypes::init()
{
    bonusPrototype_Dict = CCDictionary::create();
    bonusPrototype_Dict->retain();
    return true;
}

BonusPrototypes::~BonusPrototypes()
{
    CC_SAFE_RELEASE(bonusPrototype_Dict);
}

void BonusPrototypes::addBonus(Bonus *p_bonus)
{
    int bonus_id = p_bonus->getBonusID();
    bonusPrototype_Dict->setObject(p_bonus, bonus_id);
}

Bonus* BonusPrototypes::getBonusByID(int p_id)
{
    CCObject* tmp = bonusPrototype_Dict->objectForKey(p_id);
    
    if(tmp){
        return (Bonus*)tmp;
    }else{
        return NULL;
    }
}

